<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目状态：</label>
                        <div class="layui-input-block">
                            <select id="state" name="state" lay-filter="state">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目属性：</label>
                        <div class="layui-input-block">
                            <select id="business" name="business" lay-filter="business">
                                <option value="">请选择</option>
                                <option value="1">自营</option>
                                <option value="2">联营</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">项目所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('项目资金经营分析总表');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_zi_jing_tong),where: {}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {

                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                var state_str = '<option value="">请选择</option>';
                var state = res.data.state;
                for (var key in state){
                    if(res.data.is_state == key){
                        state_str += '<option value="'+key+'" selected>'+state[key]+'</option>';
                    }else {
                        state_str += '<option value="'+key+'">'+state[key]+'</option>';
                    }

                }
                $("#state").html(state_str);

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field: 'name', title: '项目名称'}
                ,{field: 'business_name', title: '项目属性'}
                ,{field: 'state_name', title: '项目状态'}
                ,{field:'shihemoney',title:'施工合同金额',totalRow: true,align:'right',event: 'contract_shi',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.shihemoney)+'</span>';
                    }}
                ,{field:'shimoney',title:'变更后金额 A',totalRow: true,align:'right',event: 'contract_shi',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.shimoney)+'</span>';
                    }}
                ,{field: 'lei_chan', title: '累计审定产值 B',totalRow: true,align:'right',event: 'engin_chan',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_chan)+'</span>';
                    }}
                ,{field: 'lei_piaokai', title: '累计开票 C',totalRow: true,align:'right',event: 'piao_kai',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_piaokai)+'</span>';
                    }}
                ,{field: 'lei_huikuan', title: '累计回款 D',totalRow: true,align:'right',event: 'income_engin',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_huikuan)+'</span>';
                    }}
                ,{field: 'lei_caihe', title: '采购合同总额(含变更) E',totalRow: true,align:'right',event: 'contract_cai',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_caihe)+'</span>';
                    }}
                ,{field: 'lei_jie', title: '供应商累计结算 F',totalRow: true,align:'right',event: 'gonglei',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_jie)+'</span>';
                    }}
                ,{field: 'lei_payment_engin', title: '供应商累计付款 G',totalRow: true,align:'right',event: 'payment_engin',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_payment_engin)+'</span>';
                    }}
                ,{field: 'lei_payment_bao', title: '项目费用报销 H',totalRow: true,align:'right',event: 'payment_bao',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_payment_bao)+'</span>';
                    }}
                ,{field: 'lei_piaoshou', title: '累计收票 J',totalRow: true,align:'right',event: 'piao_shou',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.lei_piaoshou)+'</span>';
                    }}
                ,{field: 'jiecha', title: '收支结算差额  B-F-H',totalRow: true,align:'right',templet: function(d){
                        if(d.jiecha < 0){
                            return '<span class="colorhong">'+parseFormatNum(d.jiecha)+'</span>';
                        }else{
                            return parseFormatNum(d.jiecha);
                        }
                    }}
                ,{field: 'hecha', title: '收支合同差额 A-E',totalRow: true,align:'right',templet: function(d){
                        if(d.hecha < 0){
                            return '<span class="colorhong">'+parseFormatNum(d.hecha)+'</span>';
                        }else{
                            return parseFormatNum(d.hecha);
                        }
                    }}
                ,{field: 'xiancha', title: '收付款差额 D-G-H',totalRow: true,align:'right',templet: function(d){
                        if(d.xiancha < 0){
                            return '<span class="colorhong">'+parseFormatNum(d.xiancha)+'</span>';
                        }else{
                            return parseFormatNum(d.xiancha);
                        }
                    }}
                ,{field: 'yingchan', title: '应收未收(按产值) B-D',totalRow: true,align:'right',templet: function(d){
                        return parseFormatNum(d.yingchan);
                    }}
                ,{field: 'yingkai', title: '应收未收(按开票) C-D',totalRow: true,align:'right',templet: function(d){
                        return parseFormatNum(d.yingkai);
                    }}
                ,{field: 'yinghe', title: '应付未付(按合同) E-G',totalRow: true,align:'right',templet: function(d){
                        if(d.yinghe < 0){
                            return '<span class="colorhong">'+parseFormatNum(d.yinghe)+'</span>';
                        }else{
                            return parseFormatNum(d.yinghe);
                        }
                    }}
                ,{field: 'yingjie', title: '应付未付(按结算) F-G',totalRow: true,align:'right',templet: function(d){
                        if(d.yingjie < 0){
                            return '<span class="colorhong">'+parseFormatNum(d.yingjie)+'</span>';
                        }else{
                            return parseFormatNum(d.yingjie);
                        }
                    }}
                ,{field: 'yingshou', title: '应付未付(按收票) J-G-H',totalRow: true,align:'right',templet: function(d){
                        if(d.yingshou < 0){
                            return '<span class="colorhong">'+parseFormatNum(d.yingshou)+'</span>';
                        }else{
                            return parseFormatNum(d.yingshou);
                        }
                    }}
                ,{field: 'chanid_name', title: '项目所属单位'}
            ]]
            , done: function (res) {
                soulTable.render(this);
            }
        });

        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'contract_shi'){
                openPage('../contract_shi/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'engin_chan'){
                openPage('../engin_chan/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'piao_kai'){
                openPage('../piao_kai/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'income_engin'){
                openPage('../income_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1&budname='+encodeURI('工程款'), '80%', '80%');
            }
            if(obj.event === 'piao_shou'){
                openPage('../piao_shou/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'payment_engin'){
                openPage('../payment_engin/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'payment_bao'){
                openPage('../payment_bao/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'contract_cai'){
                openPage('../contract_cai/tong.php?enginname='+encodeURI(data.name)+'&status=1', '80%', '80%');
            }
            if(obj.event === 'gonglei'){
                openPage('../tong_pub/gonglei.php?enginid='+data.id, '80%', '80%');
            }
        });

        listTableSearch(form, table);
    });




</script>
</body>
</html>
